import {
  BasicColumn
} from '/@/components/Table';
import {
  FormSchema
} from '/@/components/Table';
import {
  rules
} from '/@/utils/helper/validator';
import {
  render
} from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [{
    title: '料号',
    align: "center",
    sorter: true,
    dataIndex: 'code',
    width: '200px'
  },
  {
    title: '品名',
    align: "center",
    dataIndex: 'name',
    width: '300px'
  },
  {
    title: '规格',
    align: "center",
    dataIndex: 'spec',
    width: '300px'
  },
  //  {
  //   title: '料品分类ID',
  //   align:"center",
  //   dataIndex: 'marbasclassId'
  //  },
  {
    title: '主分类',
    align: "center",
    dataIndex: 'marbasclassName',
  }, {
    title: '图号',
    align: "center",
    dataIndex: 'drawingNo',
    width: '200px'
  },
  {
    title: '生产部门',
    align: "center",
    dataIndex: 'productDepartmentName',
    width: '200px'
  },
  {
    title: '班组',
    align: "center",
    dataIndex: 'teamGroupName',
    width: '200px'
  },
  {
    title: '工段',
    align: "center",
    dataIndex: 'workSectionName',
    width: '200px'
  },
  {
    title: '形态属性',
    align: "center",
    dataIndex: 'materialTypeAttribute',
    customRender: ({
      text
    }) => render.renderDict(text, 'marbas_material_type_attribute'),
    width: '100px'
  },
  //  {
  //   title: '采购控制方法',
  //   align:"center",
  //   dataIndex: 'procurementControlMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_procurement_control_method');
  //   },
  //  },
  //  {
  //   title: '计划方法',
  //   align:"center",
  //   dataIndex: 'planMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_plan_method');
  //   },
  //  },
  //  {
  //   title: '加权转换率取值时机',
  //   align:"center",
  //   dataIndex: 'weightedConversionOpportunity',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_weighted_conversion_opportunity');
  //   },
  //  },
  //  {
  //   title: '预测控制',
  //   align:"center",
  //   dataIndex: 'predictiveControl',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_predictive_control');
  //   },
  //  },
  //  {
  //   title: '核准允差原则',
  //   align:"center",
  //   dataIndex: 'approvedTolerancePrinciple',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_approved_tolerance_principle');
  //   },
  //  },
  //  {
  //   title: '计划时界原则',
  //   align:"center",
  //   dataIndex: 'planBoundPrinciple',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_plan_bound_principle');
  //   },
  //  },
  //  {
  //   title: '最高限价来源',
  //   align:"center",
  //   dataIndex: 'ceilingPriceSource',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_ceiling_price_source');
  //   },
  //  },
  //  {
  //   title: '计划时界类型',
  //   align:"center",
  //   dataIndex: 'planBoundType',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_plan_bound_type');
  //   },
  //  },
  //  {
  //   title: '退货取价来源',
  //   align:"center",
  //   dataIndex: 'returnPricingSource',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_return_pricing_source');
  //   },
  //  },
  //  {
  //   title: '发放时界类型',
  //   align:"center",
  //   dataIndex: 'provideBoundType',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_provide_bound_type');
  //   },
  //  },
  //  {
  //   title: '配额方式',
  //   align:"center",
  //   dataIndex: 'quotaMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_quota_method');
  //   },
  //  },
  //  {
  //   title: 'BOM控制方式',
  //   align:"center",
  //   dataIndex: 'bomControlMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_bom_control_method');
  //   },
  //  },
  //  {
  //   title: '配额供应商',
  //   align:"center",
  //   dataIndex: 'quotaSupplier',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_quota_supplier');
  //   },
  //  },
  //  {
  //   title: '收货程序',
  //   align:"center",
  //   dataIndex: 'receivingProcedure',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_receiving_procedure');
  //   },
  //  },
  //  {
  //   title: '规划方法',
  //   align:"center",
  //   dataIndex: 'projectMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_project_method');
  //   },
  //  },
  //  {
  //   title: '收货方式',
  //   align:"center",
  //   dataIndex: 'receivingMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_receiving_method');
  //   },
  //  },
  //  {
  //   title: '安全存量法',
  //   align:"center",
  //   dataIndex: 'safetyStockMethod',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_safety_stock_method');
  //   },
  //  },
  //  {
  //   title: '供应来源',
  //   align:"center",
  //   dataIndex: 'supplySource',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_supply_source');
  //   },
  //  },
  //  {
  //   title: '供应类型',
  //   align:"center",
  //   dataIndex: 'type',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_type');
  //   },
  //  },
  //  {
  //   title: '生产数量选择',
  //   align:"center",
  //   dataIndex: 'productionQuantitySelection',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'marbas_production_quantity_selection');
  //   },
  //  },
  {
    title: '采购预提前期（天）',
    align: "center",
    dataIndex: 'purchaseEstimateAdvance'
  },
  {
    title: '采购处理提前期（天）',
    align: "center",
    dataIndex: 'purchaseHandleAdvance'
  },
  {
    title: '采购后提前期（天）',
    align: "center",
    dataIndex: 'purchaseAfterAdvance'
  },
  {
    title: '固定提前期（天）',
    align: "center",
    dataIndex: 'regularAdvance'
  },
  {
    title: '变动提前期（天）',
    align: "center",
    dataIndex: 'changeAdvance'
  },
  {
    title: '提前期批量',
    align: "center",
    dataIndex: 'advanceBatch'
  },
  {
    title: '制造提前期（天）',
    align: "center",
    dataIndex: 'makeAdvance'
  },
  {
    title: '库存单位ID',
    align: "center",
    dataIndex: 'stockUnitId',
    ifShow: false
  },
  {
    title: '库存单位',
    align: "center",
    dataIndex: 'stockUnitName',
    width: 100
  },
  {
    title: '默认仓库ID',
    align: "center",
    dataIndex: 'warehouseId',
    ifShow: false
  },
  {
    title: '默认仓库',
    align: "center",
    dataIndex: 'warehouseName'
  },
  //  {
  //   title: '收货原则ID',
  //   align:"center",
  //   dataIndex: 'receivingPrincipleId'
  //  },
  {
    title: '安全库存量',
    align: "center",
    dataIndex: 'safetyStock'
  },
  {
    title: '参考料号',
    align: "center",
    dataIndex: 'referenceMaterialCode'
  },
  {
    title: '启用状态',
    align: "center",
    dataIndex: 'enableStatus',
    customRender: ({
      text
    }) => render.renderSwitch(text, [{
      text: '启用',
      value: '1'
    }, {
      text: '禁用',
      value: '0'
    }])
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  }
];
//查询数据
export const searchFormSchema: FormSchema[] = [{
    label: "料号",
    field: 'code',
    component: 'Input',
    colProps: {
      span: 6
    },
  },
  {
    label: "品名",
    field: 'name',
    component: 'Input',
    colProps: {
      span: 6
    },
  },
];

//表单数据
export const formSchema: FormSchema[] = [{
    label: '料号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({
      model,
      schema
    }) => {
      return [{
        required: true,
        message: '请输入料号!'
      }, ];
    },
  },
  {
    label: '品名',
    field: 'name',
    component: 'Input',
    dynamicRules: ({
      model,
      schema
    }) => {
      return [{
        required: true,
        message: '请输入品名!'
      }, ];
    },
  },
  {
    label: '规格',
    field: 'spec',
    component: 'Input',
  },
  {
    label: '料品分类ID',
    field: 'marbasclassId',
    component: 'Input',
    show: false
  },
  {
    label: '排产分类一',
    field: 'produceClassificationOne',
    component: 'Input',
    show: false,
  },
  {
    label: '排产分类二',
    field: 'produceClassificationTwo',
    component: 'Input',
    show: false,
  },
  {
    label: '排产分类三',
    field: 'produceClassificationThree',
    component: 'Input',
    show: false,
  },
  {
    label: '主分类',
    field: 'marbasclassName',
    component: 'Input',
    slot: 'marbasclassSlot',
    show: false,
  },
  {
    label: '图号',
    field: 'drawingNo',
    component: 'Input',
    show: false,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    show: false,
  },
  {
    label: '生产部门',
    field: 'productDepartmentId',
    component: 'JSelectDept',
    show: false,
    componentProps: ({}) => {
      return {
        multiple: false,
        showButton: false,
        checkable: false,
        rowKey: 'id',
        labelKey: 'departName',
        isCode: true
      }
    },
    // dynamicRules: () => {
    //   return [{
    //     required: true,
    //     message: '请选择生产部门!'
    //   },];
    // },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
// 基本信息  表单参数
export const basicFormSchema: FormSchema[] = [{
    label: '形态属性',
    field: 'materialTypeAttribute',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_material_type_attribute",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
    dynamicRules: ({
      model,
      schema
    }) => {
      return [{
        required: true,
        message: '请输入形态属性!'
      }, ];
    },
  },
  {
    label: '规划方法',
    field: 'projectMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_project_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '库存单位ID',
    field: 'stockUnitId',
    component: 'Input',
    show: false
  },
  {
    label: '库存单位',
    field: 'stockUnitName',
    component: 'Input',
    slot: 'stockUnitSlot',
    dynamicRules: ({
      model,
      schema
    }) => {
      return [{
        required: true,
        message: '请选择库存单位!'
      }, ];
    },
  },
  {
    label: '重量单位ID',
    field: 'weightUnitId',
    component: 'Input',
    show: false
  },
  {
    label: '重量单位',
    field: 'weightUnitName',
    component: 'Input',
    slot: 'weightUnitSlot',
  },
  {
    label: '体积单位ID',
    field: 'volumeUnitId',
    component: 'Input',
    show: false,
  },
  {
    label: '体积单位',
    field: 'volumeUnitName',
    component: 'Input',
    slot: 'volumeUnitSlot',
  },
  {
    label: '安全存量法',
    field: 'safetyStockMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_safety_stock_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '安全库存量',
    field: 'safetyStock',
    component: 'InputNumber',
  },
  {
    label: '需求追溯',
    field: 'requirementsTraceability',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "marbas_requirements_traceability",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '默认仓库ID',
    field: 'warehouseId',
    component: 'Input',
    show: false
  },
  {
    label: '默认仓库',
    field: 'warehouseName',
    component: 'Input',
    slot: 'warehouseSlot',
  },
  {
    label: '退货可改',
    field: 'exchangeChange',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "marbas_exchange_change",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '行业',
    field: 'trade',
    component: 'Input',
  },
  {
    label: '收货原则ID',
    field: 'receivingPrincipleId',
    component: 'Input',
    show: false
  },
  {
    label: '收货原则',
    field: 'receivingPrincipleName',
    component: 'Input',
    slot: 'receivingPrincipleSlot'
  },
  {
    label: '采购倍量',
    field: 'purchaseMultiplier',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '最小叫货量',
    field: 'minCallVolume',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '生产批量',
    field: 'productBatch',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '生产倍量',
    field: 'productMultiplier',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '发料倍量',
    field: 'materialMultiplier',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '最小发料量',
    field: 'minMaterialVolume',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
  {
    label: '补货倍量',
    field: 'replenishMultiplier',
    component: 'InputNumber',
    componentProps: {
      precision:2
    }
  },
];

// 生产信息  表单参数
export const productionFormSchema: FormSchema[] = [{
    label: '采购控制方法',
    field: 'procurementControlMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_procurement_control_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '配额供应商',
    field: 'quotaSupplier',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_quota_supplier",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '加权转换率取值时机',
    field: 'weightedConversionOpportunity',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_weighted_conversion_opportunity",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '默认供应商ID',
    field: 'supplierId',
    component: 'Input',
    show: false
  },
  {
    label: '默认供应商',
    field: 'supplierName',
    component: 'Input',
    slot: 'supplierSlot'
  },
  {
    label: '核准允差原则',
    field: 'approvedTolerancePrinciple',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_approved_tolerance_principle",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '收货程序',
    field: 'receivingProcedure',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_receiving_procedure",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '最高限价来源',
    field: 'ceilingPriceSource',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_ceiling_price_source",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '参考料号',
    field: 'referenceMaterialCode',
    component: 'Input',
  },
  {
    label: '退货取价来源',
    field: 'returnPricingSource',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_return_pricing_source",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '启用状态',
    field: 'enableStatus',
    defaultValue: 1,
    component: 'JSwitch',
    componentProps: {
      options: [1, 0]
    },
  },
  {
    label: '可退换',
    field: 'exchangeable',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "marbas_exchange_able",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '配额方式',
    field: 'quotaMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_quota_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
];

// 采购信息  表单参数
export const purchaseFormSchema: FormSchema[] = [{
    label: '计划方法',
    field: 'planMethod',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "marbas_plan_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '收货程序',
    field: 'receivingProcedure',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_receiving_procedure",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '预测控制',
    field: 'predictiveControl',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_predictive_control",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '收货方式',
    field: 'receivingMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_receiving_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '计划时界类型',
    field: 'planBoundType',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_plan_bound_type",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '供应来源',
    field: 'supplySource',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_supply_source",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '计划时界原则',
    field: 'planBoundPrinciple',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_plan_bound_principle",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '供应类型',
    field: 'type',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_type",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '发放时界类型',
    field: 'provideBoundType',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_provide_bound_type",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '日期控件',
    field: 'yyy',
    component: 'Input',
  },
  {
    label: 'BOM控制方式',
    field: 'bomControlMethod',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_bom_control_method",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '失效日期',
    field: 'jjj',
    component: 'Input',
  },
];

// 计划信息  表单参数
export const planFormSchema: FormSchema[] = [{
    label: '采购预提前期（天）',
    field: 'purchaseEstimateAdvance',
    component: 'InputNumber',
  },
  {
    label: '制造提前期（天）',
    field: 'makeAdvance',
    component: 'InputNumber',
  },
  {
    label: '采购处理提前期（天）',
    field: 'purchaseHandleAdvance',
    component: 'InputNumber',
  },
  {
    label: '汇总提前期（天）',
    field: 'gatherAdvance',
    component: 'InputNumber',
  },
  {
    label: '采购后提前期（天）',
    field: 'purchaseAfterAdvance',
    component: 'InputNumber',
  },
  {
    label: '销售预提前期（天）',
    field: 'sellEstimateAdvance',
    component: 'InputNumber',
  }, {
    label: '采购预提前期（天）',
    field: 'purchaseEstimateAdvance',
    component: 'InputNumber',
  }, {
    label: '销售处理提前期（天）',
    field: 'sellHandleAdvance',
    component: 'InputNumber',
  },
  {
    label: '固定提前期（天）',
    field: 'regularAdvance',
    component: 'InputNumber',
  },
  {
    label: '生产数量选择',
    field: 'productionQuantitySelection',
    component: 'JDictSelectTag',
    defaultValue: 0,
    componentProps: {
      dictCode: "marbas_production_quantity_selection",

      stringToNumber: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '变动提前期（天）',
    field: 'changeAdvance',
    component: 'InputNumber',
  },
  {
    label: '提前期批量',
    field: 'advanceBatch',
    component: 'InputNumber',
  },
];



/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
